import { ApiCall } from "tsrpc";
import { ReqRoomList, ResRoomList } from "../../../tsrpc/shared/protocols/room/PtlRoomList";
import { rs } from "../../../RoomServiceEntra";
import { Room } from "../../../module/room/Room";
import { RoomInfo } from "../../../tsrpc/shared/types/RoomInfo";

export default async function (call: ApiCall<ReqRoomList, ResRoomList>) {
    // TODO
    let roomList:Array<RoomInfo> = []
    rs.RoomServiceModel.rooms.forEach((room:Room,roomId:number)=>{
        roomList.push({
            id: roomId,
            name: room.RoomModel.roomName,
            num: room.RoomModel.num || 0
        })
    })
    call.succ({
        roomList:roomList
    })
}